// coding: utf8
// datetime: 2021-04-18
// 题目地址:

package main

import "fmt"

func strStr(haystack string, needle string) int {
	if needle == "" {
		return 0
	}
	ret := -1
	len_h := len(haystack)
	len_n := len(needle)
	for i, ch := range haystack {
		if len_h-i < len_n {
			return -1
		}
		if byte(ch) == needle[0] {
			ret = i
			for j, tmp := range needle {
				if haystack[i+j] != byte(tmp) {
					ret = -1
					break
				}
			}
			if ret != -1 {
				return ret
			}
		}
	}
	return ret
}

func main() {
	fmt.Println(strStr("a", "a"))
}
